﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace DnD.Model
{
    class Card : GameItem
    {
        private EntitySet<CardDeck> _decks;
        private EntitySet<CardAction> _actions;
        private string _type;
        private int _rarity;

        public Card()
        {
            this.Local = true;
            this.Rate = 0;
            this.RateCount = 0;
            this.Rarity = 0;

            _decks = new EntitySet<CardDeck>();
            _actions = new EntitySet<CardAction>();
        }

        public Card(String name, String description, String pictureURL, String type, int rarity)
        {
            this.Name = name;
            this.Description = description;
            this.PictureURL = pictureURL;
            this.Type = type;
            this.Rarity = rarity;

            this.Local = true;
            this.Rate = 0;
            this.RateCount = 0;

            _decks = new EntitySet<CardDeck>();
            _actions = new EntitySet<CardAction>();
        }

        [Column]
        public string Type
        {
            get { return _type; }
            set
            {
                _type = value;
                OnPropertyChanged();
            }
        }

        [Column(CanBeNull=true)]
        public int Rarity
        {
            get { return _rarity; }
            set
            {
                _rarity = value;
                OnPropertyChanged();
            }
        }



        [Association(Storage = "_decks", OtherKey = "CardID")]
        public EntitySet<CardDeck> Decks
        {
            get { return _decks; }
            set
            {
                _decks.Assign(value);
                OnPropertyChanged();
            }
        }

        [Association(Storage = "_actions", OtherKey = "CardID")]
        public EntitySet<CardAction> Actions
        {
            get { return _actions; }
            set
            {
                _actions.Assign(value);
                OnPropertyChanged();
            }
        }


    }
}

  
